//
//  HomeTableViewCell.m
//  大轮胎
//
//  Created by 朱永超 on 2017/3/25.
//  Copyright © 2017年 zyc. All rights reserved.
//

#import "HomeTableViewCell.h"
#import <Masonry.h>
#import <SDWebImage/UIImageView+WebCache.h>
@implementation HomeTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.homeImageV];
        [self.contentView addSubview:self.homeNameLbl];
        [self.contentView addSubview:self.homeOperateLbl];
        [self.contentView addSubview:self.homeAddressLbl];
    }
    return self;
}

-(void)setShopModel:(ShopModel *)shopModel
{
    _shopModel = shopModel;
    
    [self.homeImageV sd_setImageWithURL:[NSURL URLWithString:shopModel.logo] placeholderImage:[UIImage imageNamed:@""]];
    [self.homeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top).with.offset(10);
        make.left.mas_equalTo(self.contentView.mas_left).with.offset(10);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(100);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(-10);
    }];
    
    self.homeNameLbl.text = shopModel.name;
    [self.homeNameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top).with.offset(10);
        make.left.mas_equalTo(self.homeImageV.mas_right).with.offset(10);
    }];
    
    self.homeAddressLbl.text = shopModel.address;
    [self.homeAddressLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.homeNameLbl.mas_bottom).with.offset(10);
        make.left.mas_equalTo(self.homeImageV.mas_right).with.offset(10);
    }];
    
    self.homeOperateLbl.text = shopModel.operate;
    [self.homeOperateLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.homeAddressLbl.mas_bottom).with.offset(10);
        make.left.mas_equalTo(self.homeImageV.mas_right).with.offset(10);
    }];
    
}
/**
    @property(nonatomic , strong) UILabel *homeNameLbl;      //名字
*/
-(UILabel *)homeNameLbl
{
    if (!_homeNameLbl) {
        _homeNameLbl = [[UILabel alloc] init];
        _homeNameLbl.font = [UIFont systemFontOfSize:16];
    }
    return _homeNameLbl;
}

/**
    @property(nonatomic , strong) UILabel *homeAddressLbl;   //地址
 */
-(UILabel *)homeAddressLbl
{
    if (!_homeAddressLbl) {
        _homeAddressLbl = [[UILabel alloc] init];
        _homeAddressLbl.font = [UIFont systemFontOfSize:14];
        _homeAddressLbl.textColor = [UIColor grayColor];
    }
    return _homeAddressLbl;
}

/**
    @property(nonatomic , strong) UILabel *homeOperateLbl;   //联系人
 */
-(UILabel *)homeOperateLbl
{
    if (!_homeOperateLbl) {
        _homeOperateLbl = [[UILabel alloc] init];
        _homeOperateLbl.textColor = [UIColor grayColor];
        _homeOperateLbl.font = [UIFont systemFontOfSize:14];
    }
    return _homeOperateLbl;
}


/**
    @property(nonatomic , strong) UIImageView *homeImageV;   //图片
 */
-(UIImageView *)homeImageV
{
    if (!_homeImageV) {
        _homeImageV = [[UIImageView alloc] init];
        _homeImageV.contentMode = UIViewContentModeScaleToFill;
        _homeImageV.layer.cornerRadius = 20;
        _homeImageV.layer.masksToBounds = YES;
    }
    return _homeImageV;
}

@end
